<?php
namespace Admin\Model;
use Think\Model;

class SysconfigModel extends AbstractModel {

	protected $results = array();
	

	public $_validate = array(
    );

	protected $_auto = array(
    	
  	);
  
	
	public function Myupadd(){
		if(!$this->create()){
			$this->results['msg'] = $this->getError();
			$this->results['state'] = 0;
		}else{
			$res = $this->add();
			if($res) {
				$this->results['state'] = 1;
				$this->results['msg'] = "添加成功！";
				$this->results['id'] = $res;
			}else{
				$this->results['state'] = 0;
				$this->results['msg'] = "添加错误！";
			}
		}
		return $this->results;
	}
	
	
	public function Myupdata(){
		if(!$this->create()){
			$this->results['msg'] = $this->getError();
			$this->results['state'] = 0;
		}else{
			$res = $this->save();
			if($res) {
				$this->results['state'] = 1;
				$this->results['msg'] = "修改成功！";
				$this->results['id'] = $res;
			}else{
				$this->results['state'] = 0;
				$this->results['msg'] = "修改错误！";
			}
		}
		return $this->results;
	}
	
	public function Mydelet(){
		$dbName = $this->getTableName();
		$ID = I("ID");
		$sql = " UPDATE {$dbName} SET IsDel = 1 WHERE ID = {$ID}";
		$res = $this->execute($sql);
		if($res){
			$this->results['state'] = 1;
			$this->results['msg'] = "删除成功！";
			$this->results['id'] = $res;
		}else{
			$this->results['state'] = 0;
			$this->results['msg'] = "删除错误！";
		}
		return $this->results;
	}
	
	public function Myshow($parmArr){
		return $this->field("*")->where($parmArr)->find();
	}
	
	public function MyshowAll(){
		return $this->field("*")->select();
	}

	
	public function UpdataList(){
		$in = I();
		foreach($in AS $k => $v){
			$this->where(array("ConfigName"=>$k))->save(array("ConfigValue"=>$v));
		}
		$this->results['state'] = 1;
		$this->results['msg'] = "操作成功";
		$this->results['id'] = $res;
		return $this->results;
	}

	
}

?>				